package com.suxg.hbase.utils;

import org.springframework.lang.Nullable;

public class ValiteUtils {

	public static void main(String[] args) {
		testCheckBT();
		
	 System.out.println(checkIsEmptys("name","123","sex"," ","age","18"));
	} 

	/**
	 * 测试多个必填参数
	 */
	public static void testCheckBT() {
		
		if (checkBtIsEmptys("")) {
			System.out.println("必填参数为空1");
		}

		if (checkBtIsEmptys("123", "")) {
			System.out.println("必填参数为空2");
		}

		if (checkBtIsEmptys("123", "456", "")) {
			System.out.println("必填参数为空3");
		}
		if (checkBtIsEmptys("123", "456", "789", " ")) {
			System.out.println("必填参数为空4");
		}

		if (checkBtIsEmptys("123", "456", "789")) {
			System.out.println("必填参数为空5");
		}
	}
	/**
	 * 校验必填参数
	 */
	public static synchronized boolean checkBtIsEmptys(String... s) {
		boolean flag = false;
		for (int i = 0; i < s.length; i++) {
			flag = isEmpty(s[i]);
			if (flag) {
				break;
			}
		}

		return flag;
	}
	
	/**
	 * 校验必填参数,想知道具体哪些参数为空
	 * S 参数必须 按 k，v传递 例：“name”,"zhangsan","sex","nv',...................等
	 */
	public  static synchronized String checkIsEmptys(String... s) {
		boolean flag=false;
		String text = "";
		for (int i = 0; i < s.length; i++) {
			flag = isEmpty(s[i]);
			if (flag) {
			text=s[i-1]+"这个值为必填参数，请检查";
				break;
			}
		}

		return text;
	}
	

	public static boolean isEmpty(@Nullable Object str) {
		return (str == null || "".equals(str) || " ".equals(str));
	}
}
